package controller;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.PublicHolidayDTO;

import bizlogic.PublicHolidayManager;


/**
 * Servlet implementation class LoadPublicHolidayServlet
 */
@WebServlet("/LoadPublicHoliday")
public class LoadPublicHolidayServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LoadPublicHolidayServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doShow(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}
	private void doShow(HttpServletRequest request, HttpServletResponse response) {
		PublicHolidayManager m = new PublicHolidayManager();
		ArrayList<PublicHolidayDTO> data = m.findallpubDay();
		request.setAttribute("publicholidays", data);
		RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/ShowPublicHoliday.jsp");
		try {
			rd.forward(request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}

